﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SiteMaster : System.Web.UI.MasterPage
{
    UserPhone phone
    {
        get
        {
            if (Session["SESS_USER_PHONE"] == null)
            {
                Session["SESS_USER_PHONE"] = new UserPhone(UUID);
            }
            return Session["SESS_USER_PHONE"] as UserPhone;
        }
        set
        {
            Session["SESS_USER_PHONE"] = value;
        }
    }

    string UUID
    {
        get
        {
            string uuid = "";
            if (Request.Cookies["UUID"] != null)
            {
                uuid = Request.Cookies["UUID"].Value;
            }
            return uuid;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //lblPhoneNum.Text = UUID;// phone.PhoneNum;

        if (Request.Cookies["UUID"] == null)
        {
            HttpCookie uuidCookie;
            uuidCookie = new HttpCookie("UUID", Guid.NewGuid().ToString());
            uuidCookie.Expires = DateTime.Now.AddMonths(3);
            //delCookie1.Expires = DateTime.Now.AddDays(-1D);
            Response.Cookies.Add(uuidCookie);
        }

        if (!IsPostBack)
        {
            phone = PhoneLoader.DeserializeFromXML(UUID);
        }
 
    }
}
